
package test.jackys_one;

import android.app.Activity;
import android.app.AlertDialog;
//import android.app.Dialog;
import android.os.Bundle;
import android.widget.Button;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
//import android.view.View.OnClickListener;
//import android.app.AlertDialog;
import android.content.DialogInterface; 
import android.content.Intent;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.EditText;
import android.widget.Toast;
import java.util.Random;
import android.view.LayoutInflater;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;




public class menu2 extends Activity implements OnGestureListener{
		
		int a=0;
		TextView numbershow;
		ImageView imageshow;
		private static final int SWIPE_MIN_DISTANCE = 120; 

	    private static final int SWIPE_MAX_OFF_PATH = 250; 

	    private static final int SWIPE_THRESHOLD_VELOCITY = 200;

		private GestureDetector gestureScanner;
		
	    public void onCreate(Bundle savedInstanceState) {
	    	setTheme(android.R.style.Theme_NoTitleBar);
	    	super.onCreate(savedInstanceState);
	    	
	    	setContentView(R.layout.menu2);
	    	
	    	numbershow=(TextView)findViewById(R.id.menu2_textview01);
	    	
	    	gestureScanner = new GestureDetector(this); 
	    }
	    
	    public boolean onTouchEvent(MotionEvent event)
	    {
	    	return gestureScanner.onTouchEvent(event); 
	    	//numbershow.setText("now number is : "+a);
	    	//a=a+1;
	    	//return true;
	    }
	    
	    public boolean onDown(MotionEvent e) { // 터치 다운시에만 카운트가 증가. 안그러면 ㅋㅋ
	    	
	    	
	    	a=a+1;
	    	numbershow.setText("down : "+a);
	    	ImageView imageshow =(ImageView)findViewById(R.id.menu2_imageview01);
	    	
	    	
	    	switch(a%10)
	    	{
	    	
	    	case 0:
	    	imageshow.setImageResource(R.drawable.number0);
	    	return true; 
	    	
	    	case 1:
		    	imageshow.setImageResource(R.drawable.number1);
		    	return true; 
		    	
	    	case 2:
		    	imageshow.setImageResource(R.drawable.number2);
		    	return true; 
		    	
	    	case 3:
		    	imageshow.setImageResource(R.drawable.number3);
		    	return true; 
		    	
	    	case 4:
		    	imageshow.setImageResource(R.drawable.number4);
		    	return true; 
		    	
	    	case 5:
		    	imageshow.setImageResource(R.drawable.number5);
		    	return true; 
		    	
	    	case 6:
		    	imageshow.setImageResource(R.drawable.number6);
		    	return true; 
		    	
	    	case 7:
		    	imageshow.setImageResource(R.drawable.number7);
		    	return true; 
		    	
	    	case 8:
		    	imageshow.setImageResource(R.drawable.number8);
		    	return true; 
	    	
	    	case 9:
		    	imageshow.setImageResource(R.drawable.number9);
		    	return true;	
		    	
	    	}
	    	
	    	return true;
	    } 

	   
	    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { 

	        try { 

	            if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) 

	                return false; 

	             

	            // right to left swipe 

	            if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE 

	                    && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { 

	                Toast.makeText(getApplicationContext(), "Left Swipe", 

	                        Toast.LENGTH_SHORT).show(); 

	            } 

	            // left to right swipe 

	            else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE 

	                    && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { 

	                Toast.makeText(getApplicationContext(), "Right Swipe", 

	                        Toast.LENGTH_SHORT).show(); 

	            } 

	            // down to up swipe 

	            else if (e1.getY() - e2.getY() > SWIPE_MIN_DISTANCE 

	                    && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) { 

	                Toast.makeText(getApplicationContext(), "Swipe up", 

	                        Toast.LENGTH_SHORT).show(); 

	            } 

	            // up to down swipe 

	            else if (e2.getY() - e1.getY() > SWIPE_MIN_DISTANCE 

	                    && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) { 

	                Toast.makeText(getApplicationContext(), "Swipe down", 

	                        Toast.LENGTH_SHORT).show(); 

	            } 

	        } catch (Exception e) { 

	             

	        } 

	 

	        return true; 

	    } 

	 

	    public void onLongPress(MotionEvent e) { 

	     //   Toast mToast = Toast.makeText(getApplicationContext(), "Long Press", Toast.LENGTH_SHORT); 

	      //  mToast.show(); 

	    } 

	 

	    public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { 

	    //	numbershow.setText("scroll : "+a); 

	       return true; 

	    } 

	 

	    public void onShowPress(MotionEvent e) { 

	    //	numbershow.setText("show press : "+a); 

	    } 

	 

	    public boolean onSingleTapUp(MotionEvent e) { 

	    //    Toast mToast = Toast.makeText(getApplicationContext(), "Single Tap", Toast.LENGTH_SHORT); 

	   //     mToast.show(); 

	        return true; 

	    } 

	    
	} 


	    
	    